package com.toby.ioc.aware;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

/**
 * @desc: 应用中需要获取spring的上下文
 * @author: toby
 * @date: 2019/7/13 1:15
 */
@Component
public class TobyApplicationContextAware implements ApplicationContextAware {
    /**
     * spring上下文
     */
    private ApplicationContext applicationContext;
    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        System.out.println("应用程序获取到了spring 容器");
        this.applicationContext = applicationContext;
    }
}
